//////////////////////////////////////////////////////////////////////////
//
// GAM203
// D3DX mesh from an .x file
// MeshX.h
// 
// Scott Taylor
// Qantm College
//
//////////////////////////////////////////////////////////////////////////

#ifndef MESHX_H
#define MESHX_H

#include "Drawable.h"

#include <d3d9.h>
#include <d3d9types.h>

#include <vector>

class MeshX : public Drawable
{
public:
	MeshX();
	//Virtual d'tor because of inheritance
	virtual ~MeshX();

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For creating the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	// a_pTexFileName, a path passed into the function. This can either be used for
	// the texture file name, or for a mesh's file name.
	//
	// Returns false if any step of the creation failed
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	virtual bool CreateObject(IDirect3DDevice9* a_pDevice, char* a_pTexFileName);

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For rendering the drawable object
	//
	// Paramaters:
	// a_dt, the delta time
	// a_pDevice, the direct3d device
	// a_renderParams, the struct used for rendering
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	virtual void Render(float a_dt, IDirect3DDevice9* a_pDevice, const RenderParams& a_renderParams);

	ID3DXMesh* GetMesh() const { return m_pMesh; }
	ID3DXMesh** GetShadowMesh() { return &m_pShadowMesh; }

	void RenderShadow(IDirect3DDevice9* a_pDevice, const RenderParams& a_renderParams);

private:
	//Mesh used by the class
	ID3DXMesh* m_pMesh;
	// Number of segments in mesh 
	DWORD m_segmentCount; 

	//Mesh used by the class
	ID3DXMesh* m_pShadowMesh;

	// List of materials on mesh (pairs of material structs with a single texture ptr each)
	typedef std::pair<D3DMATERIAL9, IDirect3DTexture9*> MaterialTexturePair;
	typedef std::vector<MaterialTexturePair> MaterialList;
	MaterialList m_materials;
};

#endif  // MESHX_H
